package org.lex.game.sudoku.model.visitor;

import org.lex.game.sudoku.model.SudokuModel;
import org.lex.game.sudoku.model.SudokuModelListener.Cause;

public final class CopyModelVisitor implements ModelVisitor<Integer> {
	private final SudokuModel dest;
	private int numberCount;

	public CopyModelVisitor(SudokuModel dest) {
		this.dest = dest;
	}

	@Override
	public VisitResult visit(SudokuModel source, int row, int col, int num) {
		this.numberCount++;
		dest.set(Cause.USER, row, col, num);
		return VisitResult.CONTINUE;
	}

	@Override
	public Integer finish() {
		return this.numberCount;
	}
}